package com.jiangyg.mall.member.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.member.dao.MemberCollectSubjectDao;
import com.jiangyg.mall.member.dto.MemberCollectSubjectDTO;
import com.jiangyg.mall.member.entity.MemberCollectSubject;
import com.jiangyg.mall.member.vo.MemberCollectSubjectVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MemberCollectSubjectServiceImpl extends BaseServiceImpl<MemberCollectSubjectDao, MemberCollectSubject> implements MemberCollectSubjectService {

    @Autowired
    public MemberCollectSubjectServiceImpl(MemberCollectSubjectDao memberCollectSubjectDao) {
        super(memberCollectSubjectDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<MemberCollectSubjectVO> selectPagination(Pagination<MemberCollectSubjectVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, MemberCollectSubjectVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(MemberCollectSubjectDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public MemberCollectSubjectVO selectById(Long memberCollectSubjectId) throws Exception {
        return this.executeSelectById(memberCollectSubjectId, MemberCollectSubjectVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> memberCollectSubjectIds) {
        return this.baseMapper.deleteBatchIds(memberCollectSubjectIds) > 0;
    }

}
